<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="itheima" uri="http://itheima.com/common/"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() 
	                   + ":" + request.getServerPort() + path + "/";
	session.setAttribute("role", "admin");
%>
<!DOCTYPE HTML>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>校园百事通</title>
	<!-- 引入css样式文件 -->
	<!-- Bootstrap Core CSS -->
	<link href="<%=basePath%>css/bootstrap.min.css" rel="stylesheet" />
	<!-- MetisMenu CSS -->
	<link href="<%=basePath%>css/metisMenu.min.css" rel="stylesheet" />
	<!-- DataTables CSS -->
	<link href="<%=basePath%>css/dataTables.bootstrap.css" rel="stylesheet" />
	<!-- Custom CSS -->
	<link href="<%=basePath%>css/sb-admin-2.css" rel="stylesheet" />
	<!-- Custom Fonts -->
	<link href="<%=basePath%>css/font-awesome.min.css" rel="stylesheet" type="text/css" />
	<link href="<%=basePath%>css/boot-crm.css" rel="stylesheet" type="text/css" />
<!-- 引入js文件 -->
<!-- jQuery -->
<script src="<%=basePath%>js/jquery-1.11.3.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="<%=basePath%>js/bootstrap.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="<%=basePath%>js/metisMenu.min.js"></script>
<!-- DataTables JavaScript -->
<script src="<%=basePath%>js/jquery.dataTables.min.js"></script>
<script src="<%=basePath%>js/dataTables.bootstrap.min.js"></script>
<!-- Custom Theme JavaScript -->
<script src="<%=basePath%>js/sb-admin-2.js"></script>
<script type="text/javascript">
	
	// 通过id获取修改的管理员信息
	function editAdmin1(id) {
	    $.ajax({
	        type:"get",
	        url:"<%=basePath%>admin/getAdminById.action",
	        data:{"id":id},
	        cache:false,
	        success:function(data) {;
	            $("#edit_id1").val(data.id);
	            $("#edit_adminName1").val(data.admin_name);
	        }
	    });
	}
	function update() {
		$.post("<%=basePath%>admin/update.action",
		$("#admin_form").serialize(),function(data){
			if(data =="OK"){
				alert("管理员信息更新成功！");
				window.location.reload();
			}else if(data=="name"){
				alert("管理员信息更新失败！名称不能为空");
				window.location.reload()
			}else if(data=="Aname"){
				alert("管理员信息更新失败！名称已存在");
				window.location.reload()
			}else if(data=="paw"){
				alert("管理员信息更新失败！旧密码错误");
				window.location.reload()
			}else{
				alert("管理员信息更新失败！");
				window.location.reload();
			}
		});
	}
</script>
</head>
<body>
<div id="wrapper">
  <!-- 导航栏部分 -->
  <nav class="navbar navbar-default navbar-static-top" role="navigation"
		 style="margin-bottom: 0">
	<div class="navbar-header">
		<h2 onclick="index()">校园百事通后台管理</h2> 
	</div>
	<!-- 导航栏右侧图标部分 -->
	<ul class="nav navbar-top-links navbar-right">
	    <!-- 邮件通知 start -->
		<li class="dropdown">
			<a class="dropdown-toggle" data-toggle="dropdown" href="#"> 
				<i class="fa fa-envelope fa-fw"></i>
				<i class="fa fa-caret-down"></i>
			</a>
			<ul class="dropdown-menu dropdown-messages">
				<li>
				    <a href="#">
				    </a>
				</li>
				<li class="divider"></li>
				<li>
				    <a class="text-center" href="#">
				        <strong>查看全部消息</strong>
						<i class="fa fa-angle-right"></i>
				    </a>
				</li>
			</ul>
		</li>
		<!-- 邮件通知 end -->
		<!-- 管理员信息和系统设置 start -->
		<li class="dropdown">
			<a class="dropdown-toggle" data-toggle="dropdown" href="#"> 
				<i class="fa fa-user fa-fw"></i>
				<i class="fa fa-caret-down"></i>
			</a>
			<ul class="dropdown-menu dropdown-user">
				<li><a data-toggle="modal" data-target="#adminEditDialog1" onclick= "editAdmin1(${Admin_SESSION.id})"><i class="fa fa-user fa-fw"></i>
				               管理员：${Admin_SESSION.admin_name}
				    </a>
				</li>
				<li class="divider"></li>
				<li>
					<a href="${pageContext.request.contextPath }/adminlogout.action">
					<i class="fa fa-sign-out fa-fw"></i>退出登录
					</a>
				</li>
			</ul> 
		</li>
		<!-- 管理员信息和系统设置结束 -->
	</ul>
	
	<!-- 左侧显示列表部分 start-->
	<div class="navbar-default sidebar" role="navigation">
		<div class="sidebar-nav navbar-collapse">
			<ul class="nav" id="side-menu">
				<li class="sidebar-search">
					<div class="input-group custom-search-form">
					</div> 
				</li>
				<li>
				    <a href="${pageContext.request.contextPath }/user/list.action" class="active">
				      <i class="fa fa-user fa-fw"></i> 用户管理
				    </a>
				</li>
				<li>
				    <a href="${pageContext.request.contextPath }/admin/list.action" class="active">
				      <i class="fa fa-user fa-fw" ></i> 管理员管理
				    </a>
				</li>
				<li>
				    <a href="${pageContext.request.contextPath }/information/list.action" class="active">
				      <i class="fa fa-edit fa-fw"></i> 校园资讯管理
				    </a>
				</li>
				<li>
				    <a href="${pageContext.request.contextPath }/losearticle/list.action" class="active">
				      <i class="fa fa-dashboard fa-fw" ></i> 失物招领/寻物启事管理
				    </a>
				</li>
			</ul>
		</div>
	</div>
	<!-- 左侧显示列表部分 end--> 
  </nav>
  </div>
  
  
<!-- 管理员信息模态框 -->
<div class="modal fade" id="adminEditDialog1" tabindex="-1" role="dialog"
	aria-labelledby="myModalLabel">
	<div class="modal-dialog" role="document">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
				<h4 class="modal-title" id="myModalLabel">管理员信息</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal" id="admin_form">
					<input type="hidden" id="edit_id1" name="id"/>
					<div class="form-group">
						<label for="edit_adminName" class="col-sm-2 control-label" style="float:left;padding:7px 15px 0 27px;">名称</label>
						<div class="col-sm-10">
							<input type="text" class="form-control" id="edit_adminName1" placeholder="请输入管理员名称" name="admin_name" />
						</div>
					</div>
					<div class="form-group">
						<label for="edit_oldPassword" class="col-sm-2 control-label" style="float:left;padding:7px 15px 0 27px;">旧密码</label>
						<div class="col-sm-10"> 
							<input type="password" class="form-control" id="edit_Password" placeholder="请输入旧密码" name="password" />
						</div>
					</div>
					<div class="form-group">
						<label for="edit_newPassword" class="col-sm-2 control-label" style="float:left;padding:7px 15px 0 27px;">新密码</label>
						<div class="col-sm-10">
							<input type="password" class="form-control" id="edit_newPassword" placeholder="请输入新密码" name="newpassword" />
						</div>
					</div>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				<button type="button" class="btn btn-primary" onclick="update()">保存修改</button>
			</div>
		</div>
	</div>
</div>
  </body>
  </html>